var contextPath = "/";
$(function () {
    contextPath += window.location.pathname.split("/")[1];//    /WorkManager
   $("#save").click(function () {
      if(baocun()){//当条件都满足时
          submit();
      } 
   });
});
//onsubmit函数当返回值为true可以提交，否则不提交
function baocun() {
    var studentname=$("#xingming").val();
    var studentnumber=$("#xuehao").val();
    var studentbirth=$("#birthday").val();
    var studentclass=$("#banji").val();
    if(studentname==""){
        alert("姓名不能为空!");
        return false;
    }
    if(studentnumber==""){
        alert("学号不能为空!");
        return false;
    }
    //在此处判断，保证出生年月日不为空
    if(studentbirth==""){
        alert("出生年月不能为空!");
        return false;
    }
    if(studentclass==""){
        alert("班级不能为空!");
        return false;
    }
    return true;

}
function submit() {//向后台提交数据

    var url=contextPath+"/information/changeinfo.wm";
    var data={};
    data.xingming=$("#xingming").val();
    data.sex=$("#sex").val();
    data.xuehao=$("#xuehao").val();
    data.banji=$("#banji").val();
    data.major=$("#major").val();
    data.phonenumber=$("#phonenumber").val();
    data.school=$("#school").val();
    data.birthday=$("#birthday").val();
    data.qqnumber=$("#qqnumber").val();
    data.weixin=$("#weixin").val();
    data.address=$("#address").val();
    data.interexts=$("#interexts").val();
    data.qianming=$("#qianming").val();
    $.ajaxSetup({
        async:false//设置同步
    });
    $.post(url,data,function (result,status) {
        if(status=="success"){
            if(result.Whethersaved){
                alert("保存成功!");
            }
        }

    },"json");
    
}
